<?php

if (!defined('EXPONENT')) exit('');

$link = null;
if (isset($_GET['id'])) {
	$link = $db->selectObject('cauthay_item','id='.$_GET['id']);
	if ($link) {
		$loc = unserialize($link->location_data);
	}
}

if (($link && exponent_permissions_check('edit',$loc)) || (!$link && exponent_permissions_check('create',$loc))) {
	$form = cauthay_item::form($link);
	$form->location($loc);
	$form->meta('action','save');
	
	$template = new template('cauthaymodule','_form_edit');
	$template->assign('is_edit',($link == null ? 0 : 1));
	$template->assign('form_html',$form->toHTML());
	$template->output();
} else {
	echo SITE_404_HTML;
}

?>
